#ifndef _GEO_SURMANAGER_H_
#define _GEO_SURMANAGER_H_

#include "GeometryBase.h"

class CLineManager;
class CVertexManager;
class CCurveManager;
class CSketchModel;

class CSurfaceManager
{
	friend class CSketchModel;
public:
	CSurfaceManager();
	CSurfaceManager(CVertexManager* pVertexManager, CLineManager* pLineManager, CCurveManager* pCurveManager);
	~CSurfaceManager();

	CSurface GetSurface(int index);
	int GetSurfaceCount();

	void InferSurface(int curveSegment);

protected:

private:
	vector<CSurface> m_surfaces;
	CLineManager* m_pLineManager;
	CVertexManager* m_pVertexManager;
	CCurveManager* m_pCurveManager;

	void InferSurfaceFromCurrentLine(
		int baseLine, 
		int currentLine, 
		CVertex* curStart,
		CVertex* curEnd,
		CSurface& surface
		);
	void TrimToSimpleSurface();
	bool IsInSurface(CSurface surface, CLineSegment line);
	bool IsInSurface(CSurface surface, CVertex3D v);

	void SegmentAllCurves(int curveSegment, int &newVertexCount, int &newLineSegmentCount);
	void SegmentCurvePairs(CCurve curve1, CCurve curve2, int curveSegment);
};


#endif